<?php
require_once ("db_connection.php");
session_start();
$session_id='1'; //$session id
$path = "../uploads/file/";
$id = "FI-" . uniqid();
$date = date("Y-m-d H:i:s");
$affiliateid = $_POST['affiliateid'];


	$valid_formats = array("php");
	if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST")
		{
			$name = $_FILES['photoimg']['name'];
			$size = $_FILES['photoimg']['size'];
			
			if(strlen($name))
				{
					list($txt, $ext) = explode(".", $name);
					if(in_array($ext,$valid_formats))
					{
					if($size<(5024*5024))
						{
							$actual_image_name = $txt.".".$ext;
							$tmp = $_FILES['photoimg']['tmp_name'];
							if(move_uploaded_file($tmp, $path.$actual_image_name))
								{
								//mysql_query("UPDATE users SET profile_image='$actual_image_name' WHERE uid='$session_id'");
									echo "<img src='images/table/check.png' height='30' width='30'>";
									$newpath = 'uploads/file/';
									$newpaths = $newpath.$actual_image_name;
									$_SESSION['varname1'] = $newpaths;
									
								}
							else
								echo "<font color='red'>failed </font>";
						}
						else
						echo "<font color='red'> Image file size max 2 MB </font>";					
						}
						else
						echo "<font color='red'> Invalid file format.. </font>";	
				}
				
			else
				echo "<font color='red'>Please select image..! </font>";
				
			exit;
	
		}
		
?>